package com.mocne.MocneAutoTest;

import com.google.gson.Gson;
import okhttp3.*;

import java.io.IOException;
import java.util.HashMap;

public class test {

    public void main(String[] args) throws IOException {
        SendPost2GetData();
    }

    public void SendPost2GetData() throws IOException {
        System.out.println("SendPost2GetData");
        OkHttpClient client = new OkHttpClient().newBuilder()
                .build();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\"loginSource\": \"ERP\",\"username\": \"anl1chn\",\"password\": \"111111\"\n}");
        Request.Builder request = new Request.Builder();
        request.url("http://erp.test.jimuitech.com/platform/admin/auth/login");
        request.method("POST", body);
        request.addHeader("Content-Type", "application/json");
        request.addHeader("countryId", "1001");
        Request restests = request.build();
        Response response = client.newCall(restests).execute();
        Gson gson = new Gson();
        HashMap test = new HashMap<>();
        if (response.body() != null) {
            test = gson.fromJson(response.body().string(), test.getClass());
        }
        System.out.println(test);
    }
}
